package mao.thinkinjava.array;

import java.util.*;

public class TestLambada {
    public static void main(String[] args) {
        Comparable<Integer> com=(a)->a;
        int i = com.compareTo(3);
        System.out.println(i);

        //lambada类似于C++里面的回调函数。
        Comparator<Integer> comparator = (o1,o2)->o1-o2;
        int compare = comparator.compare(3, 4);
        System.out.println(compare);

        //List<Integer> list = new ArrayList<Integer>();

        Integer[] a = {1,2,4,4,5,6};
        Comparator<Object> objectComparator = Collections.reverseOrder();
        //这里对于实现了Comparable的对象，Collections.reverseOrder()才有效果。
        Arrays.sort(a,objectComparator);
        System.out.println(Arrays.toString(a));
    }
}
